package com.qeado.site.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.qeado.admin.common.BaseConstData;
import com.qeado.common.helper.AttributeHelper;
import com.qeado.site.model.SiteContactInfo;
import com.qeado.site.service.SiteContactInfoManageService;;

@Controller
public class SiteContactInfoManageController {

	@Autowired
	private SiteContactInfoManageService siteContactInfoManageService;
	
	@RequestMapping("/siteContactInfo.ac")
	public ModelAndView showSiteInfo(HttpServletRequest request){
		AttributeHelper.removeSessionAttribute(request, "T_");
		SiteContactInfo siteContactInfo = this.siteContactInfoManageService.getSiteConactInfo();
		return new ModelAndView("site/contact_manage","siteContactInfo",siteContactInfo);
	}
	
	@RequestMapping("/siteContactInfoSave.ac")
	public ModelAndView saveNewSiteInfo(HttpServletRequest request, SiteContactInfo siteContactInfo){
		siteContactInfo.setCreator(request.getSession().getAttribute(BaseConstData.USER_ID).toString());
		this.siteContactInfoManageService.saveSiteContactInfo(siteContactInfo);
		//show new message
		SiteContactInfo temp = this.siteContactInfoManageService.getSiteConactInfo();
		return new ModelAndView("site/contact_manage","siteContactInfo",temp);
		
	}
	
}
